package com.xylx.interview.loadbalance;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * 负载均衡算法
 * 完全随机算法
 */
public class RandomServer {

    public static List<String> list = Arrays.asList("10.180.11.126:8888", "10.180.11.128:8888", "10.180.11.130:8888");

    static Random random = new Random();

    public static String getServer() {
        int number = random.nextInt(list.size());
        return list.get(number);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 15; i++) {
            System.out.println(getServer());
        }
    }
}